package com.community.system.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.community.common.annotation.Log;
import com.community.common.core.controller.BaseController;
import com.community.common.core.domain.AjaxResult;
import com.community.common.enums.BusinessType;
import com.community.system.domain.PatrolPoint;
import com.community.system.service.IPatrolPointService;
import com.community.common.utils.poi.ExcelUtil;
import com.community.common.core.page.TableDataInfo;

/**
 * pointController
 * 
 * @author ruoyi
 * @date 2025-10-27
 */
@RestController
@RequestMapping("/system/point")
public class PatrolPointController extends BaseController
{
    @Autowired
    private IPatrolPointService patrolPointService;

    /**
     * 查询point列表
     */
    @PreAuthorize("@ss.hasPermi('system:point:list')")
    @GetMapping("/list")
    public TableDataInfo list(PatrolPoint patrolPoint)
    {
        startPage();
        List<PatrolPoint> list = patrolPointService.selectPatrolPointList(patrolPoint);
        return getDataTable(list);
    }

    /**
     * 导出point列表
     */
    @PreAuthorize("@ss.hasPermi('system:point:export')")
    @Log(title = "point", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PatrolPoint patrolPoint)
    {
        List<PatrolPoint> list = patrolPointService.selectPatrolPointList(patrolPoint);
        ExcelUtil<PatrolPoint> util = new ExcelUtil<PatrolPoint>(PatrolPoint.class);
        util.exportExcel(response, list, "point数据");
    }

    /**
     * 获取point详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:point:query')")
    @GetMapping(value = "/{patrolPointId}")
    public AjaxResult getInfo(@PathVariable("patrolPointId") Long patrolPointId)
    {
        return success(patrolPointService.selectPatrolPointByPatrolPointId(patrolPointId));
    }

    /**
     * 新增point
     */
    @PreAuthorize("@ss.hasPermi('system:point:add')")
    @Log(title = "point", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PatrolPoint patrolPoint)
    {
        return toAjax(patrolPointService.insertPatrolPoint(patrolPoint));
    }

    /**
     * 修改point
     */
    @PreAuthorize("@ss.hasPermi('system:point:edit')")
    @Log(title = "point", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PatrolPoint patrolPoint)
    {
        return toAjax(patrolPointService.updatePatrolPoint(patrolPoint));
    }

    /**
     * 删除point
     */
    @PreAuthorize("@ss.hasPermi('system:point:remove')")
    @Log(title = "point", businessType = BusinessType.DELETE)
	@DeleteMapping("/{patrolPointIds}")
    public AjaxResult remove(@PathVariable Long[] patrolPointIds)
    {
        return toAjax(patrolPointService.deletePatrolPointByPatrolPointIds(patrolPointIds));
    }
}
